libxc: Save the HVM_PARAM_ACPI_IOPORTS_LOCATION
authorAnthony Perard <anthony.perard@citrix.com>
Mon, 8 Nov 2010 17:25:54 +0000 (17:25 +0000)
committerAnthony Perard <anthony.perard@citrix.com>
Mon, 8 Nov 2010 17:25:54 +0000 (17:25 +0000)
This will save the acpi_ioport_location hvm_param in the checkpoint file
and set the parameter in Xen at restore.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/libxc/xc_domain_restore.c
tools/libxc/xc_domain_save.c
tools/libxc/xg_save_restore.h

index 6225e0ed948d6f91080f448ba8a0c69fa5b0936b..f868283059ad3e063fedc608ee1c82c80bdb4f13 100644 (file)
@@ -669,6 +669,7 @@ typedef struct {
     uint64_t identpt;
     uint64_t vm86_tss;
     uint64_t console_pfn;
+    uint64_t acpi_ioport_location;
 } pagebuf_t;
 
 static int pagebuf_init(pagebuf_t* buf)
@@ -793,6 +794,16 @@ static int pagebuf_get_one(xc_interface *xch, struct restore_ctx *ctx,
         // DPRINTF("last checkpoint indication received");
         return pagebuf_get_one(xch, ctx, buf, fd, dom);
 
+    case XC_SAVE_ID_HVM_ACPI_IOPORTS_LOCATION:
+        /* Skip padding 4 bytes then read the acpi ioport location. */
+        if ( RDEXACT(fd, &buf->acpi_ioport_location, sizeof(uint32_t)) ||
+             RDEXACT(fd, &buf->acpi_ioport_location, sizeof(uint64_t)) )
+        {
+            PERROR("error read the acpi ioport location");
+            return -1;
+        }
+        return pagebuf_get_one(xch, ctx, buf, fd, dom);
+
     default:
         if ( (count > MAX_BATCH_SIZE) || (count < 0) ) {
             ERROR("Max batch size exceeded (%d). Giving up.", count);
@@ -1342,6 +1353,15 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,
             fcntl(io_fd, F_SETFL, orig_io_fd_flags | O_NONBLOCK);
     }
 
+    if (pagebuf.acpi_ioport_location == 1) {
+        DBGPRINTF("Use new firmware ioport from the checkpoint\n");
+        xc_set_hvm_param(xch, dom, HVM_PARAM_ACPI_IOPORTS_LOCATION, 1);
+    } else if (pagebuf.acpi_ioport_location == 0) {
+        DBGPRINTF("Use old firmware ioport from the checkpoint\n");
+    } else {
+        ERROR("Error, unknow acpi ioport location (%i)", pagebuf.acpi_ioport_location);
+    }
+
     if ( ctx->last_checkpoint )
     {
         // DPRINTF("Last checkpoint, finishing\n");
index 27b38a62393dd82e15c540cccaac28564776c6d9..675611b15d4d29ef9d0dac4efd097268a39e68bf 100644 (file)
@@ -1628,6 +1628,16 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iter
             PERROR("Error when writing the console pfn for guest");
             goto out;
         }
+
+        chunk.id = XC_SAVE_ID_HVM_ACPI_IOPORTS_LOCATION;
+        xc_get_hvm_param(xch, dom, HVM_PARAM_ACPI_IOPORTS_LOCATION,
+                         (unsigned long *)&chunk.data);
+
+        if ((chunk.data != 0) && wrexact(io_fd, &chunk, sizeof(chunk)))
+        {
+            PERROR("Error when writing the firmware ioport version");
+            goto out;
+        }
     }
 
     if ( !callbacks->checkpoint )
index b13bdef649dde1cd52b4e36c110f46e3d64dd907..02116012e2a55fb7268a92ad9a93db6a0b8edb25 100644 (file)
 #define XC_SAVE_ID_TSC_INFO           -7
 #define XC_SAVE_ID_HVM_CONSOLE_PFN    -8 /* (HVM-only) */
 #define XC_SAVE_ID_LAST_CHECKPOINT    -9 /* Commit to restoring after completion of current iteration. */
+#define XC_SAVE_ID_HVM_ACPI_IOPORTS_LOCATION -10
 
 /*
 ** We process save/restore/migrate in batches of pages; the below